﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Web.API.Model;

namespace Web.API.UI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UpLoadController : ControllerBase
    {
        public UpLoadController(IWebHostEnvironment web) 
        {
            Web = web;
        }
        public IWebHostEnvironment Web {  get;}
        [HttpPost("upload")]
        public IActionResult upload(IFormFile file)
        {
            var a=Guid.NewGuid().ToString();
            var b = Web.WebRootPath + @"\pic\" +a+ file.FileName;
            using (FileStream fs=System.IO.File.Create(b))
            {
                file.CopyTo(fs);
                fs.Close();
            }
            return Ok("/pic/"+a+file.FileName);

        }
      
    }
}
